package loads

import (
	"jvm/instructions/base"
	"jvm/rtda"
)

// LLOAD Load long from local variable
type LLOAD struct{ base.Index8Instruction }

func (ll *LLOAD) Execute(jFrame *rtda.JFrame) {
	_lload(jFrame, ll.Index)
}

type LLOAD_0 struct{ base.NoOperandsInstruction }

func (ll *LLOAD_0) Execute(jFrame *rtda.JFrame) {
	_lload(jFrame, 0)
}

type LLOAD_1 struct{ base.NoOperandsInstruction }

func (ll *LLOAD_1) Execute(jFrame *rtda.JFrame) {
	_lload(jFrame, 1)
}

type LLOAD_2 struct{ base.NoOperandsInstruction }

func (ll *LLOAD_2) Execute(jFrame *rtda.JFrame) {
	_lload(jFrame, 2)
}

type LLOAD_3 struct{ base.NoOperandsInstruction }

func (ll *LLOAD_3) Execute(jFrame *rtda.JFrame) {
	_lload(jFrame, 3)
}

func _lload(jFrame *rtda.JFrame, index uint) {
	val := jFrame.LocalVars().GetLong(index)
	jFrame.OperandStack().PushLong(val)
}
